<%@ page import="com.entity.Blog" %>
<%@ page import="java.util.List" %>
<%@ page import="com.dao.BlogDao" %>
<%@ page import="com.dao.BlogDaoImpl" %><%--
  Created by IntelliJ IDEA.
  User: Elle
  Date: 2022/6/16
  Time: 9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>显示博客列表</title>
  </head>
  <style>
    table,div{
      width: 800px;
      border: 1px solid;
    }
    td{
      border: 1px solid;
    }
  </style>
  <body>
  <%
//    BlogDao blogDao = new BlogDaoImpl();
    List<Blog> list = (List<Blog>) request.getAttribute("blogList");//blogDao.findAll(); //获取数据
  %>
  <p>
    <a href="#">新增</a>
  </p>
  <div>
    <form action="doList.jsp">
      <h4>查询条件</h4>
      <p>发布博客的用户编号：<input type="text" name="uid"></p>
      <p>博客状态：
            <select name="state">
                <option value="-1">请选择</option>
                <option value="1">原创 </option>
                <option value="2">转发</option>
            </select></p>
     <p> 内容：<input type="text" name="content"></p>
     <p> <input type="submit" value="查询"></p>
    </form>
  </div>
  <table>
    <tr>
      <td>编号</td>
      <td>用户id</td>
      <td>内容</td>
      <td>创建时间</td>
      <td>状态</td>
      <td>操作</td>
    </tr>

    <%
      for (Blog tmp : list){
    %>
      <tr>
        <td><%=tmp.getId()%></td>
        <td><%=tmp.getUid()%></td>
        <td><%=tmp.getContent()%></td>
        <td><%=tmp.getTime()%></td>
        <td><%=tmp.getState()%></td>
        <td>
          <a href="javascript:del(<%=tmp.getId()%>); " >删除</a>
          <a href="doUpdateInfo.jsp?id=<%=tmp.getId()%>">修改</a>
        </td>
      </tr>
    <%}%>

  </table>
  </body>

<script>
  function del(id) {
    var bool = confirm("您确定删除吗？");
    if(bool){//确定
      location.href="doDelete.jsp?id="+id;
    }
  }
</script>
</html>
